function next_event=time_setter(event_clock)

global NUMBER_OF_EVENTS TNOW BIG 


  minimum=BIG;


  % Find out which event is next 

  for index=1:NUMBER_OF_EVENTS
  
    if event_clock(index)<=minimum
    
      minimum=event_clock(index);

      next_event=index;

    end

  end

  % advance simulation clock 


  TNOW=minimum;


